<!--#Include File="Include.asp"--><%
'--------------------------------------
'Power By 方卡在线 @2010-2014 f02
'URL:http://www.fangka.net/
'EMail:admin@ifangka.com
'QQ:861118936
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Call CheckAdminType("0,1",UType)
Call CheckAdminLimit(ULimit,"o_Recommend",0)

Dim Fk_Recommend_Name

Types=Clng(Request.QueryString("Type"))

Select Case Types
	Case 1
		Call RecommendList() '推荐类型列表
	Case 2
		Call RecommendAddForm() '添加推荐类型表单
	Case 3
		Call RecommendAddDo() '执行添加推荐类型
	Case 4
		Call RecommendEditForm() '修改推荐类型表单
	Case 5
		Call RecommendEditDo() '执行修改推荐类型
	Case 6
		Call RecommendDelDo() '执行删除推荐类型
	Case Else
		Call FKFun.ShowErr("未发现功能项！",1)
End Select

'==========================================
'函 数 名：RecommendList()
'作    用：推荐类型列表
'==========================================
Sub RecommendList()
%>
		<div id="rightNav">
			<ul>
				<li><a href="Recommend.asp?Type=2" target="dialog" width="500">添加推荐类型</a></li>
			</ul>
		</div>
		<div id="searchLine" class="font_bold">
			推荐类型管理
		</div>
		<table width="100%" bordercolor="#CCCCCC" border="1" cellspacing="0" cellpadding="0">
			<tr>
				<th align="center">ID</th>
				<th align="center">名称</th>
				<th align="center">操作</th>
			</tr>
<%
	Sqlstr="Select Fk_Recommend_Id,Fk_Recommend_Name From [Fk_Recommend] Order By Fk_Recommend_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		i=1
		While Not Rs.Eof
%>
			<tr>
				<td height="20" align="center"><%=Rs("Fk_Recommend_Id")%></td>
				<td align="center"><%=Rs("Fk_Recommend_Name")%></td>
				<td align="center"><a href="Recommend.asp?Type=4&Id=<%=Rs("Fk_Recommend_Id")%>" target="dialog" width="500">修改</a> <a href="Recommend.asp?Type=6&Id=<%=Rs("Fk_Recommend_Id")%>" target="delete" confirmStr="您确认要删除“<%=Rs("Fk_Recommend_Name")%>”？此操作不可逆！" refreshUrl="Recommend.asp?Type=1" showStr="名称删除成功！">删除</a></td>
			</tr>
<%
			Rs.MoveNext
			i=i+1
		Wend
	Else
%>
			<tr>
				<td height="25" colspan="20" align="center">暂无记录</td>
			</tr>
<%
	End If
	Rs.Close
%>
			<tr>
				<td height="30" colspan="20">&nbsp;</td>
			</tr>
		</table>
		<div id="rightBottom">
		
		</div>
<%
End Sub

'==========================================
'函 数 名：RecommendAddForm()
'作    用：添加推荐类型表单
'==========================================
Sub RecommendAddForm()
%>
<form id="RecommendAdd" name="RecommendAdd" method="post" target="ajax" action="Recommend.asp?Type=3" showStr="新推荐类型添加成功！" refreshUrl="Recommend.asp?Type=1" boxClose="1">
<div id="title">添加新推荐类型</div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="24%" height="30" align="right">名称：</td>
			<td width="76%">&nbsp;<input name="Fk_Recommend_Name" type="text" class="input" id="Fk_Recommend_Name" /><span class="help" title="<p>推荐类型名称，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
	</table>
</div>
<div id="bottom">
	<input type="submit" class="button" name="Enter" id="Enter" value="添 加" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub

'==============================
'函 数 名：RecommendAddDo
'作    用：执行添加推荐类型
'==============================
Sub RecommendAddDo()
	Fk_Recommend_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Recommend_Name")))
	Call FKFun.JsonString(Fk_Recommend_Name,1,50,0,"请输入名称！","名称不能大于50个字符！")
	Sqlstr="Select Fk_Recommend_Id,Fk_Recommend_Name From [Fk_Recommend] Where Fk_Recommend_Name='"&Fk_Recommend_Name&"'"
	Rs.Open Sqlstr,Conn,1,3
	If Rs.Eof Then
		Application.Lock()
		Rs.AddNew()
		Rs("Fk_Recommend_Name")=Fk_Recommend_Name
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("该推荐类型名称已经被占用！")
	End If
	Rs.Close
End Sub

'==========================================
'函 数 名：RecommendEditForm()
'作    用：修改推荐类型表单
'==========================================
Sub RecommendEditForm()
	Id=Clng(Request.QueryString("Id"))
	Sqlstr="Select Fk_Recommend_Name From [Fk_Recommend] Where Fk_Recommend_Id=" & Id
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		Fk_Recommend_Name=Rs("Fk_Recommend_Name")
	Else
		Rs.Close
		Call FKFun.ShowErr("推荐类型不存在！",1)
	End If
	Rs.Close
%>
<form id="RecommendEdit" name="RecommendEdit" method="post" target="ajax" action="Recommend.asp?Type=5" showStr="推荐类型修改成功！" refreshUrl="Recommend.asp?Type=1" boxClose="1">
<div id="title">修改推荐类型</div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="24%" height="30" align="right">名称：</td>
			<td width="76%">&nbsp;<input name="Fk_Recommend_Name" type="text" class="input" id="Fk_Recommend_Name" value="<%=Fk_Recommend_Name%>" /><span class="help" title="<p>推荐类型名称，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
	</table>
</div>
<div id="bottom">
	<input type="hidden" name="Id" value="<%=Id%>" />
	<input type="submit" class="button" name="Enter" id="Enter" value="修 改" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub

'==============================
'函 数 名：RecommendEditDo
'作    用：执行修改推荐类型
'==============================
Sub RecommendEditDo()
	Fk_Recommend_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Recommend_Name")))
	Id=Trim(Request.Form("Id"))
	Call FKFun.JsonString(Fk_Recommend_Name,1,50,0,"请输入名称！","名称不能大于50个字符！")
	Call FKFun.JsonNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_Recommend_Id,Fk_Recommend_Name From [Fk_Recommend] Where Fk_Recommend_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs("Fk_Recommend_Name")=Fk_Recommend_Name
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("要修改的推荐类型不存在！")
	End If
	Rs.Close
End Sub

'==============================
'函 数 名：RecommendDelDo
'作    用：执行删除推荐类型
'==============================
Sub RecommendDelDo()
	Id=Trim(Request.QueryString("Id"))
	Call FKFun.ShowNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_View_Id From [Fk_View] Where Fk_View_Recommend Like '%%,"&Id&",%%'"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		Call FKFun.ShowErr("该推荐类型在使用中，无法删除！",2)
	End If
	Rs.Close
	Sqlstr="Select Fk_Recommend_Id From [Fk_Recommend] Where Fk_Recommend_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs.Delete()
		Application.UnLock()
		Response.Write("ok")
	Else
		Response.Write("要删除的推荐类型不存在！")
	End If
	Rs.Close
End Sub

Call FKFun.PageEnd()
%>
